package org.urchr.beorganized.api.impl;

import org.urchr.beorganized.api.base.PrivateBaseAPIServlet;
import org.urchr.beorganized.dao.NotesDAO;
import org.urchr.beorganized.dao.XMLDocumentBuilder;
import org.urchr.beorganized.dao.errors.GeneralException;

public class ChangeSort extends PrivateBaseAPIServlet{

	@Override
	protected void doProcessPrivate() throws GeneralException {
		int noteID = NotesDAO.safeInt(request.getParameter("noteid"), -1);
		int sort = NotesDAO.safeInt(request.getParameter("sort"), 0);
		int sortType = NotesDAO.safeInt(request.getParameter("sorttype"), 0);
		NotesDAO.changeSort(userID, noteID, sort, sortType);
		XMLDocumentBuilder doc = new XMLDocumentBuilder();
		doc.getRootElement("note").setAttribute("id", ""+noteID);
		sendNode(doc.getRootElement());
	}

}
